package com.booter.webflux.filter;

import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebExchangeDecorator;

public class BodyServerWebExchangeDecorator extends ServerWebExchangeDecorator {

    private RequestBodyServerHttpRequestDecorator requestDecorator;

    private ResponseBodyServerHttpResponseDecorator responseDecorator;

    public BodyServerWebExchangeDecorator(ServerWebExchange delegate) {
        super(delegate);
        requestDecorator = new RequestBodyServerHttpRequestDecorator(delegate.getRequest());
        responseDecorator = new ResponseBodyServerHttpResponseDecorator(delegate.getResponse());
    }

    @Override
    public ServerHttpRequest getRequest() {
        return requestDecorator;
    }

    @Override
    public ServerHttpResponse getResponse() {
        return responseDecorator;
    }
}